package com.ten.stat.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ten.stat.vo.EduCourseVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ：王薪伟
 * @date ：Created in 2022/12/13 17:46
 * @description：
 * @modified By：
 * @version:
 */
public interface EduCourseDao extends BaseMapper<EduCourseVo> {

    @Select("SELECT sub.title,c.buy_count AS buyCount FROM edu_course c JOIN " +
            "(SELECT su.id,su.title, COUNT(su.parent_id) FROM edu_subject s JOIN (" +
            "SELECT * FROM edu_subject WHERE parent_id = '0') su ON su.id = s.parent_id GROUP BY s.parent_id) sub " +
            "on c.subject_parent_id = sub.id GROUP BY sub.title;")
    List<EduCourseVo> selectCount();
}
